﻿@model iDMS.Models.Drawing
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary()
    <fieldset>
        <legend>Drawing</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Identifier)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Identifier, new { @id = "TitleTextBox", @style = "width:400px;height:45px;" })
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.isPart)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.isPart)
        </div>
        <div class="editor-label">
            Foreign part
        </div>
        <div class="editor-field">
            @if (ViewBag.isHouse)
            {
                <input type="checkbox" name="isForeign" id="cbHouse"/>
            }
            else
            {
                <input type="checkbox" name="isForeign" id="cbHouse" checked="checked"/>
            }
        </div>
        <div class="infobox hidden" id="extra">
            <div class="editor-label">
                @Html.LabelFor(model => model.ManufacturerID)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.ManufacturerID, (IEnumerable<SelectListItem>)ViewBag.Manufacturers)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.ManufacturerPartNo)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ManufacturerPartNo)
            </div>
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.DesignChangeID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.DesignChangeID, (IEnumerable<SelectListItem>)ViewBag.DesignChanges)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.UnitID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.UnitID, (IEnumerable<SelectListItem>)ViewBag.Units)
        </div>
        <p>
            <input type="submit" value="Submit" />
        </p>
    </fieldset>
}
    
    @if (ViewBag.isHouse)
    {
        <script type="text/javascript">
            //Hide div w/id extra
            $("#extra").css("display", "none");
        </script>
    }
    
     
    <script type="text/javascript">


        // Add onclick handler to checkbox w/id checkme
        $("#cbHouse").click(function () {

            // If checked
            if ($("#cbHouse").is(":checked")) {
                //show the hidden div
                $("#extra").show();
            }
            else {
                //otherwise, hide it
                $("#extra").hide();
            }
        });

    </script>
